package controllers;

import java.util.Date;

import models.HitchhikerJourney;
import models.User;
import play.data.validation.Required;
import play.mvc.With;

import common.FBSecure;

@With(FBSecure.class)
public class StartHitcJourneyInfo extends FBController{
	
	public static void starthitcjourneyinfo(@Required String departurestate,
			@Required String departuretownn, @Required String departurestreet, @Required Date departuredate,
			@Required String departurehour, @Required String arrivestate,
			@Required String arrivetownn, @Required String arrivestreet, String journeynotes, 
			@Required boolean priceshare ){
		
		setFbIdandName();

		User user = getUser();
		
		if (validation.hasErrors()) {
			renderTemplate("StartHitcJourneyInfo/starthitcjourneyinfo.html", user);
		}
		
		HitchhikerJourney hitcJourney = user.addStartHitcJourney(user, departurestate, departuretownn, departurestreet, departuredate, departurehour,
				arrivestate, arrivetownn, arrivestreet, journeynotes, priceshare );

		String msg = "Seyahatiniz oluşturuldu!";
		
		renderTemplate("HitcJourneyDetails/hitcjourneydetails.html", user, hitcJourney, msg);	
	}
}

